
import '../../sass/pubComponents/Header.scss';

export default {
    data(){
        return {
            username:'',
            username_dsp:'',
            date:''
        }
    },
    props: [],
    components:{

    },
    computed: {

    },
    created:function () {

    },
    mounted:function () {
        setTimeout(()=>{
            this.username = sessionStorage.username;
            this.username_dsp = sessionStorage.username_dsp;
        },100);
        let myDate = new Date();
        this.date = '登录时间：'+myDate.toLocaleDateString()+ ' '+ myDate.toLocaleTimeString();
    },
    methods: {
        async logout(){  //获得操作记录列表
            let _this=this,response,_response;

            try {
                response = await fetch('backend/auth/logout', {
                    method: 'GET',
                    headers: {
                        'Accept': 'application/json',
                        'Content-type': "application/json",
                    },
                    credentials: 'same-origin'
                });
                _response = await response.json();
                if(_response.code ===0 ){
                    sessionStorage.clear();
                    window.location.href='/backend';
                }else{
                    _this.$message.error(_response.msg);
                }
            } catch(err) {
                _this.$message.error('请求失败');
            }
        },
    }
}